#include <cstdio>
#include <map>

using namespace std;

map<int,double> mm;

void readFile( char* fname ) {
  freopen( fname, "r", stdin );
  scanf( "%*s" );
  int id;
  double val;
  while ( scanf( "%d,%lf", &id, &val ) != EOF )
    mm[id] += val;
}

int main( int argc, char* argv[] ) {
  for ( int i = 1; i < argc; i++ )
    readFile( argv[i] );
  printf( "RefId,IsBadBuy\n" );
  for ( map<int,double>::iterator it = mm.begin(); it != mm.end(); it++ )
    printf( "%d,%.5f\n", it->first, it->second / (argc-1) );
  return 0;
}